<?php 
/**
 * TomatoCMS
 * 
 * LICENSE
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE Version 2 
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-2.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@tomatocms.com so we can send you a copy immediately.
 * 
 * @copyright	Copyright (c) 2009-2010 TIG Corporation (http://www.tig.vn)
 * @license		http://www.gnu.org/licenses/gpl-2.0.txt GNU GENERAL PUBLIC LICENSE Version 2
 * @version 	$Id: result.phtml 5244 2010-08-31 07:47:26Z huuphuoc $
 * @since		2.0.0
 */
?>
<?php if ($this->question) : ?>
<div class="t_poll_vote">
    <h2><?php echo $this->question->title; ?></h2>

	<div><?php echo $this->question->content; ?></div>
	
	<?php if ($this->answers) : ?>
	<div>
		<?php foreach ($this->answers as $answer) : ?>
		<div class="result">
			<div style="width: <?php if ($this->count > 0) : ?><?php echo floor($answer->num_views * 100 / $this->count); ?>%"<?php endif; ?>">&nbsp;</div>
		</div>
		<span><?php echo $answer->title; ?> - <?php echo $answer->num_views; ?> <?php echo $this->translator()->widget('votes'); ?> (<?php if ($this->count > 0) : ?><?php echo floor($answer->num_views * 100 / $this->count); ?>%<?php endif; ?>)</span>
		<?php endforeach; ?>
	</div>
	<?php endif; ?>
	
	<button id="pollVoteBackButton" class="button"><span><?php echo $this->translator()->widget('back_button'); ?></span></button>
</div>

<script type="text/javascript">
$(document).ready(function() {
	$('#pollVoteBackButton').click(function() {
		Tomato.Core.Widget.Loader.queue('poll', 'vote', '<?php echo addslashes($this->data); ?>', '<?php echo $this->container; ?>');
	});
});
</script>
<?php endif; ?>
